// 登录方式切换
let logins = document.querySelectorAll(".login")
let boxs = document.querySelectorAll(".box")
logins.forEach(function(i, index) {
    i.addEventListener("click", function(e) {
        logins.forEach(function(item) {
            item.classList.remove("active")
        })
        logins[index].classList.add("active")
        e.preventDefault()
        boxs.forEach(function(item) {
            item.classList.remove("on")
        })
        boxs[index].classList.add("on")

    })


})

// 登录
let btn = document.querySelector(".btn")




function inputUsername() {
    let input1 = document.querySelector(".input1")
    let true1 = document.querySelector(".true1")
    input1.addEventListener("blur", function() {

        // console.log("111");
        if (input1.value.length > 11 || input1.value.length < 3) {
            // console.log(input1.value.length);
            true1.style.display = "block"
        }

    })
    input1.addEventListener("focus", function() {
        // console.log("111");
        // if (input1.value.length != 11) {
        // console.log(input1.value.length);
        true1.style.display = "none"
            // }

    })
}
inputUsername()

function inputPassword() {

    let input2 = document.querySelector(".input2")
    let true2 = document.querySelector(".true2")

    input2.addEventListener("blur", function() {
        // console.log("111");
        if (input2.value.length === 0) {
            // console.log(input1.value.length);
            true2.style.display = "block"
        }

    })
    input2.addEventListener("focus", function() {
        // console.log("111");
        // if (input1.value.length != 11) {
        // console.log(input1.value.length);
        true2.style.display = "none"
            // }

    })
}
inputPassword()

function buttonUsname() {
    let btn = document.querySelector(".twobox .box .btn")
    let input1 = document.querySelector(".input1")
    let input2 = document.querySelector(".input2")

    btn.addEventListener("click", function() {
        if (input1.value !== "lmr") {
            return alert("账号或密码错误")
        }
        if (input2.value !== "123") {
            return alert("账号或密码错误")
        }
        alert("登录成功，正在跳转")
        setTimeout(function() {
            location.href = `./index.html? usname=lmr`
        }, 1000)
    })
}
buttonUsname()